package 笔试;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class 三六零_复制粘贴 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int T = scan.nextInt();
        scan.nextLine();
        String[] s = new String[T];
        String[] t = new String[T];
        int m = 0;
        int n = 0;
        for (int i = 0; i < 2*T; i++) {
            if(i % 2 == 0) {
                s[m++] = scan.nextLine();
            } else {
                t[n++] = scan.nextLine();
            }
        }
        for (int i = 0; i < T; i++) {
            if(s[i].equals(t[i])) {
                System.out.println("YES");
            } else if(s[i].length() > t[i].length()){
                System.out.println("NO");
            } else {
                HashSet<Character> set = new HashSet<>();
                for (int j = 0; j < t[i].length(); j++) {
                    set.add(t[i].charAt(j));
                }
                for (int j = 0; j < s[i].length(); j++) {
                    if(!set.contains(s[i].charAt(j))) {
                        System.out.println("NO");
                        break;
                    }else if(j == s[i].length()-1) {
                        System.out.println("YES");
                        break;
                    }
                }
            }
        }
    }
}
